<!DOCTYPE html>
<html lang="en"
      xmlns:th="http://www.thymeleaf.org"
      xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
      layout:decorator="/admin/_layouts/default">
<head>
    <title>修改角色信息</title>
</head>
<body>
<div layout:fragment="content">
        <!-- 内容区域 -->
        <section class="content">
            <!-- Small boxes (Stat box) -->
            <div class="row">
                <div class="col-xs-12 i-navbar">
                    <a class="btn btn-primary" th:href="@{/admin/system/role/index.html}" data-pjax><i
                            class="fa fa-arrow-left"></i> 返回
                    </a>
                </div>
                <div class="col-xs-12">
                    <div class="box box-primary">
                        <div class="box-header with-border">
                            <h3 class="box-title">更新角色信息</h3>
                        </div>
                        <div class="box-body">
                            <form id="systemVariableForm"
                                  class="stepy"
                                  th:action="@{/admin/system/role/update}"
                                  method="POST">
                                <input type="hidden" name="id" th:value="${role.id}">
                                <div class="box-body">
                                    <div class="form-group">
                                        <label for="department">所属单位</label>
                                        <input type="text" class="form-control" id="department"
                                               placeholder="请选择单位或系统角色"
                                               th:value="${role.department?.name}"
                                               readonly/>
                                    </div>
                                    <div class="form-group">
                                        <label for="name">角色名称</label>
                                        <input class="form-control" id="name" name="name"
                                               placeholder="请输入角色名称"
                                               required
                                               readonly
                                               th:value="${role.name}"
                                               type="text"/>
                                    </div>
                                    <div class="form-group">
                                        <label for="role">权限标识</label>
                                        <input class="form-control" id="role" name="role"
                                               placeholder="请输入权限标识"
                                               th:value="${role.role}"
                                               required
                                               readonly
                                               type="text">
                                    </div>
                                    <div class="form-group">
                                        <label for="description">角色说明</label>
                                        <textarea class="form-control" id="description" name="description"
                                                  placeholder="请输入 ..."
                                                  style="resize:none"
                                                  th:text="${role.description}"
                                                  rows="3"></textarea>
                                    </div>
                                </div>
                                <button class="stepy-finish btn btn-primary pull-right">完成</button>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
            <!-- /.row -->
        </section>
        <!-- /内容区域 -->
        <script>
            var tree;
            $(function () {
                $('#systemVariableForm').ajaxForm({
                    dataType: 'json',
                    beforeSubmit: function (arr, form, option) {
                        form.find("button:submit").attr('disable', true);
                        if (form.attr("isSubmit") === undefined) {//与stepy结合使用时，要避免二次提交的问题
                            form.attr("isSubmit", true);
                        } else {
                            form.removeAttr("isSubmit");
                            return false;
                        }
                    },
                    success: function (data, statusText, xhr, form) {
                        if (data.code === 200) {
                            layer.msg(data.message, {icon: 1});
                        } else {
                            layer.msg(data.message, {icon: 2});
                        }
                        form.find("button:submit").attr('disable', false);
                    }
                });
            });
        </script>
    </div>
</body>
</html>
